*---------------------------------------------------------------
* Script : Sample - Speech Recognition	
* Date   : 1st Feb 2006														
* Notes  : Example Speech Recognition Script for Audio Juke Box 		
*---------------------------------------------------------------
Online IVR Tutorial

MAIN:

    srKeepGrammar(true)
    srAcceptWords("zero","one","two","three","four","five","six","seven","eight","nine")

    answer	
    play "welcome.wav"

    $retry = 3
    while $retry > 1
		
    * Accept a number 
    play "song.wav"
    while true
        $Key = input(1,7)
        if $InputMode == "S"
            if srConfidence() >= 100
                break
            endif
        else
            break
        endif
    endwhile
		
    if $InputMode == "S"
        * Perform a translation to the appropriate keypress
        if $Key == "zero"
            $Key = 0
        endif
        if $Key == "one"
            $Key = 1
        endif
        if $Key == "two"
            $Key = 2
        endif
        if $Key == "three"
            $Key = 3
        endif
        if $Key == "four"
            $Key = 4
        endif
        if $Key == "five"
            $Key = 5
        endif
        if $Key == "six"
            $Key = 6
        endif
        if $Key == "seven"
            $Key = 7
        endif
        if $Key == "eight"
            $Key = 8
        endif
        if $Key == "nine"
            $Key = 9
        endif
    endif		
		
    if $Key = 0
        break
    endif    
		
    if $Key <> ""
        play Format("Music%d.wav",$Key)
        $retry = 3
    endif
    $retry -= 1
    endwhile

    play "thank.wav"
    hangup
    goto MAIN

* User has hung up
ONHANGUP:
    hangup
    goto MAIN

* An error has occurred
ONSYSTEMERROR:
    log $error
    display $error
    if $debug 
        msgbox $error
    endif

    hangup
    goto MAIN